﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Z2.Core
{
	public class Field
	{
		private WorldField m_foreground;
		private WorldField m_background;
		private Vector2 m_position;
		private bool m_isSolid;
		private bool m_isWater;

		public bool ContainsWater
		{
			get { return this.m_isWater; }
		}

		/// <summary>
		/// Vrací zda je toto políčko průchozí
		/// </summary>
		public bool IsSolid
		{
			get { return this.m_isSolid; }
		}

		public Vector2 Position
		{
			get { return this.m_position; }
			set { this.m_position = value; }
		}

		public WorldField Foreground
		{
			get { return this.m_foreground; }
			set 
			{
				this.m_foreground = value;
				if (value.IsSolid) this.m_isSolid = true;
				if (value.IsWater)
				{
					this.m_isWater = true;
					value.Sprite.Visibility = 0.5F;
				}
			}
		}

		public WorldField Background
		{
			get { return this.m_background; }
			set 
			{ 
				this.m_background = value;
				if (value.IsSolid) this.m_isSolid = true;
				if (value.IsWater)
				{
					this.m_isWater = true;
					value.Sprite.Visibility = 0.5F;
				}
			}
		}

		public void Draw(SpriteBatch batch, Vector2 position)
		{
			if (this.m_background != null) this.m_background.Draw(batch, position);
			if (this.m_foreground != null) this.m_foreground.Draw(batch, position);
		}
	}
}
